﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using nplJobsCommon.Common;
using System.Data;
using System.Data.SqlClient;

namespace nplJobsDAL.Common
{
    public class JobCategoryDAL:DataAccessBase
    {
        public  List<JobCategory> GetList(JobCategory obj, string strMode)
        {
            DataBaseHelper dbHelper;
            DataSet ds;
            try
            {
                dbHelper = new DataBaseHelper("SP_JOBCATEGORY");
                SqlParameter prm = new SqlParameter("@ID", SqlDbType.Int);
                prm.Value = obj.ID;
                SqlParameter prm1 = new SqlParameter("@CATEGORY", SqlDbType.Int);
                prm1.Value = obj.Caterogy;
                SqlParameter prm2 = new SqlParameter("@strMode", DbType.String);
                prm2.Value = strMode;


                SqlParameter[] prmCollection = { prm, prm1,prm2 };

                dbHelper.Parameters = prmCollection;
                ds = dbHelper.Run(base.ConnectionString, dbHelper.Parameters);

                List<JobCategory> results = new List<JobCategory>();

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    JobCategory objData = new JobCategory();

                    MapperBase.GetInstance().MapItem(objData, dr); ;
                    results.Add(objData);
                }
                return results;

            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    }
}
